/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Issam
 */
@Entity
@Table(name = "ENTREPRISE", catalog = "", schema = "NETTRADING")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Entreprise.findAll", query = "SELECT e FROM Entreprise e"),
    @NamedQuery(name = "Entreprise.findByIdEntreprise", query = "SELECT e FROM Entreprise e WHERE e.idEntreprise = :idEntreprise"),
    @NamedQuery(name = "Entreprise.findByNom", query = "SELECT e FROM Entreprise e WHERE e.nom = :nom"),
    @NamedQuery(name = "Entreprise.findByTelephone", query = "SELECT e FROM Entreprise e WHERE e.telephone = :telephone"),
    @NamedQuery(name = "Entreprise.findByAdresse", query = "SELECT e FROM Entreprise e WHERE e.adresse = :adresse")})
public class Entreprise implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID_ENTREPRISE", nullable = false)
    @GeneratedValue(strategy= GenerationType.AUTO)
    private Short idEntreprise;
    @Basic(optional = false)
    @Column(name = "NOM", nullable = false, length = 20)
    private String nom;
    @Basic(optional = false)
    @Column(name = "TELEPHONE", nullable = false)
    private int telephone;
    @Basic(optional = false)
    @Column(name = "ADRESSE", nullable = false, length = 40)
    private String adresse;
    @OneToMany(mappedBy = "idEntreprise")
    private Collection<Client> clientCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idEntreprise")
    private Collection<Action> actionCollection;

    public Entreprise() {
    }

    public Entreprise(Short idEntreprise) {
        this.idEntreprise = idEntreprise;
    }

    public Entreprise(Short idEntreprise, String nom, int telephone, String adresse) {
        this.idEntreprise = idEntreprise;
        this.nom = nom;
        this.telephone = telephone;
        this.adresse = adresse;
    }

    public Short getIdEntreprise() {
        return idEntreprise;
    }

    public void setIdEntreprise(Short idEntreprise) {
        this.idEntreprise = idEntreprise;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public int getTelephone() {
        return telephone;
    }

    public void setTelephone(int telephone) {
        this.telephone = telephone;
    }

    public String getAdresse() {
        return adresse;
    }

    public void setAdresse(String adresse) {
        this.adresse = adresse;
    }

    @XmlTransient
    public Collection<Client> getClientCollection() {
        return clientCollection;
    }

    public void setClientCollection(Collection<Client> clientCollection) {
        this.clientCollection = clientCollection;
    }

    @XmlTransient
    public Collection<Action> getActionCollection() {
        return actionCollection;
    }

    public void setActionCollection(Collection<Action> actionCollection) {
        this.actionCollection = actionCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idEntreprise != null ? idEntreprise.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Entreprise)) {
            return false;
        }
        Entreprise other = (Entreprise) object;
        if ((this.idEntreprise == null && other.idEntreprise != null) || (this.idEntreprise != null && !this.idEntreprise.equals(other.idEntreprise))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "test.entities.Entreprise[ idEntreprise=" + idEntreprise + " ]";
    }
    
}
